package com.fz.us.admin.company.entity;

import com.fz.us.admin.company.bean.FlowEnum;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by ZhuChunXiao on 2017/2/14.
 * 任务实例表(流程引擎基础）
 */
@Entity
@Table(name="sys_taskentity")
public class TaskEntity extends CompanyEntity {


    private static final long serialVersionUID = 4591621831853138200L;
    //文档id
    private String keyId;

    //所属的实体类名
    private String entityName;

    //当前的步骤编号
    private int stepNo;

    //上一步操作人
    private Set<User> prevUsers;

    //当前阅读者
    private Set<User> readers;

    //当前编辑者
    private Set<User> editors;

    //文档状态
    private FlowEnum.ProcessState processState;


    public String getKeyId() {
        return keyId;
    }

    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }

    public String getEntityName() {
        return entityName;
    }

    public void setEntityName(String entityName) {
        this.entityName = entityName;
    }

    public int getStepNo() {
        return stepNo;
    }

    public void setStepNo(int stepNo) {
        this.stepNo = stepNo;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_taskentity_prevusers", joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="prevUsersId"))
    public Set<User> getPrevUsers() {
        return prevUsers;
    }

    public void setPrevUsers(Set<User> prevUsers) {
        this.prevUsers = prevUsers;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_taskentity_readers", joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="readersId"))
    public Set<User> getReaders() {
        return readers;
    }

    public void setReaders(Set<User> readers) {
        this.readers = readers;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_taskentity_editors", joinColumns = @JoinColumn(name="id"),inverseJoinColumns = @JoinColumn(name="editorsId"))
    public Set<User> getEditors() {
        return editors;
    }

    public void setEditors(Set<User> editors) {
        this.editors = editors;
    }

    @Column(name="processState", length = 10)
    @Enumerated(EnumType.STRING)
    public FlowEnum.ProcessState getProcessState() {
        return processState;
    }

    public void setProcessState(FlowEnum.ProcessState processState) {
        this.processState = processState;
    }
}
